
	** ETHIOPIA: CLEAN WAVE 2
		
	 * prep consumption file 
	 use "$dir/rawdata/LSMS Ethiopia/2013/cons_agg_w2.dta", clear
	 
	 ren nom_totcons_aeq w2_conspc
	 ren hh_size w2_hhsize_fromcons
	 
	 keep household_id2 w2*
	 tempfile consumption
	 save `consumption', replace
	 use "$dir/rawdata/LSMS Ethiopia/2013/sect1_hh_w2.dta", clear // ROSTER
	 merge 1:1 household_id2 individual_id2 using "$dir/rawdata/LSMS Ethiopia/2013/sect3_hh_w2.dta", assert(master matched) nogen // HEALTH
	 merge 1:1 household_id2 individual_id2 using "$dir/rawdata/LSMS Ethiopia/2013/sect4_hh_w2.dta", assert(master matched) nogen // LABOR
	 merge m:1 household_id2 using `consumption', assert(master matched) nogen // CONSUMPTION
	 
		 /*
		 Section 1: Roster
		 Section 2: Education
		 Section 3: Health
		 Section 4: Time use and labor	 
		 Section 5a&b: Food consumption
		 Section 6: Non-food expenditure
		 Section 7: Food security
		 Section 8: Shocks
		 Section 9: Housing
		 Section 10: Assets
		 Section 11: Non-farm enterprise
		 Section 12: Other income
		 Section 13: Assistance
		 Section 14: Credit
		 */
		 
	 ren household_id2 hhid
	 gen indiv=substr(individual_id2,strlen(individual_id2)-1,2)
	 destring indiv, replace
	 assert indiv==hh_s1q00
	 
	 ** INFORMATION FROM HOUSEHOLD ROSTER

		** Still in HH
			gen w2_inhh=hh_s1q04c!=2
		
		** Age
			gen w2_age=hh_s1q04_a
			replace w2_age=hh_s1q04h if !missing(hh_s1q04h)
			
		** Household size
			gen temp=1 if w2_inhh==1
			bys hhid: egen w2_hh_size=total(temp)
			drop temp

		** Number of children 12 or younger
			gen temp=1 if w2_age<=12 & w2_inhh==1
			bys hhid: egen w2_hh_under12=total(temp)
			drop temp

		** Number of youth 18 or younger
			gen temp=1 if w2_age<=18 & w2_inhh==1
			bys hhid: egen w2_hh_under18=total(temp)
			drop temp

		** Number of adults 60 or older
			gen temp=1 if w2_age>=60 & !missing(w2_age) & w2_age!=999 & w2_inhh==1
			bys hhid: egen w2_hh_over60=total(temp)
			drop temp

		** Adults 12 to 60
			gen temp=1 if w2_age>12 & w2_age<60 & !missing(w2_age) & w2_age!=999 & w2_inhh==1
			bys hhid: egen w2_hh_12to60=total(temp)
			drop temp

		** Marital status
			gen w2_married=(hh_s1q08==2 | hh_s1q08==3) if !missing(hh_s1q08)
			gen w2_married_monog=(hh_s1q08==2) if !missing(hh_s1q08)
			gen w2_married_polyg=(hh_s1q08==3) if !missing(hh_s1q08)

		** Female
			gen w2_female=(hh_s1q03==2) if !missing(hh_s1q03)
			replace w2_female=(hh_s1q04e==2) if !missing(hh_s1q04e)

		** Age of spouse
			sum indiv
			forvalues x=1/`r(max)' {
				gen age_person`x'_temp=w2_age if indiv==`x' & !missing(w2_age)
				bys hhid: egen age_person`x'=max(age_person`x'_temp)
				drop age_person`x'_temp
			}

		** Average age of others in the household
			sum indiv 
			forvalues x=1/`r(max)' {
				replace age_person`x'=. if indiv==`x'
			}
			egen w2_hh_avgage=rowmean(age_person*)
			
		** Spouse age
			sum indiv
			forvalues x=1/`r(max)' {
				replace age_person`x'=. if hh_s1q10!=`x'
			}
			egen w2_spouse_age=rowmean(age_person*)

		** Age gap
			gen w2_spouse_agegap=w2_age-w2_spouse_age

		** Birthday
			gen w2_birthday=mdy(hh_s1q04g_2,hh_s1q04g_1,hh_s1q04g_3)
			format w2_birthday %td
			
		** Birth year
			gen w2_birthyear=hh_s1q04g_3
			recode w2_birthyear 9999=. 9998=.
			replace w2_birthyear=2013-w2_age if missing(w2_birthyear)
	
	***********
	***********
	
	** Geographic information
	
		gen w2_geo_urban=(rural==2 | rural==3) if !missing(rural)
		
	***********
	***********

	** LABOR

		** Worked for a non-HH member
			egen w2_work_outsideHH_hrs=rowtotal(hh_s4q06 hh_s4q07), mi
			gen w2_work_outsideHH=w2_work_outsideHH_hrs>0 if !missing(w2_work_outsideHH_hrs)
		
		** Worked in agriculture for a HH member
			gen w2_work_agHH_hrs=hh_s4q04
			gen w2_work_agHH=w2_work_agHH_hrs>0 if !missing(w2_work_agHH_hrs)
			
		** Worked in HH business
			gen w2_work_bizHH_hrs=hh_s4q05
			gen w2_work_bizHH=w2_work_bizHH_hrs>0 if !missing(w2_work_bizHH_hrs)

		** Any work in last 7 days (agriculture, for non-HH member, own account/business)
			egen w2_worked_last7days=rowmax(w2_work_outsideHH w2_work_agHH w2_work_bizHH)
			
		** Hours worked in last 7 days
			egen w2_work_hrs=rowtotal(w2_work_outsideHH_hrs w2_work_agHH_hrs w2_work_bizHH_hrs)
			replace w2_work_hrs=. if missing(w2_work_outsideHH_hrs) & missing(w2_work_agHH_hrs) & missing(w2_work_bizHH_hrs)

		** Works in agriculture
			gen w2_work_agri=(hh_s4q11_b==1 | hh_s4q11_b==2 | hh_s4q22_b==1 | hh_s4q22_b==2 | w2_work_agHH==1) if (!missing(hh_s4q11_b) | !missing(hh_s4q22_b) | !missing(w2_work_agHH))
		
	***********
	***********

	** HEALTH
		
		** Any illness or injury during the last 2 months
			gen w2_ill_inj=(hh_s3q01==1) if !missing(hh_s3q01)

		** Had to stop usual activity in the past 1 weeks
			gen w2_ill_inj_stopactivity=(hh_s3q03>0) if !missing(hh_s3q03)
			replace w2_ill_inj_stopactivity=0 if w2_ill_inj==0

	***********
	***********

	** DISABILITIES

		** Difficulty seeing
			tab1 hh_s3q12, nol
			tab1 hh_s3q12
			gen w2_diff_seei=1 if inlist(hh_s3q12, 2, 3, 4) 
			replace w2_diff_seei=0 if inlist(hh_s3q12, 1)
			replace w2_diff_seei=. if inlist(hh_s3q12, .)
			tab1 w2_diff_seei

		** Difficulty hearing
			tab1 hh_s3q13, nol
			tab1 hh_s3q13
			gen w2_diff_hear=1 if inlist(hh_s3q13, 2, 3, 4) 
			replace w2_diff_hear=0 if inlist(hh_s3q13, 1)
			replace w2_diff_hear=. if inlist(hh_s3q13, .)
			tab1 w2_diff_hear

		** Difficulty walking or climbing stairs	
			tab1 hh_s3q14, nol
			tab1 hh_s3q14
			gen w2_diff_walk_clim=1 if inlist(hh_s3q14, 2, 3, 4) 
			replace w2_diff_walk_clim=0 if inlist(hh_s3q14, 1)
			replace w2_diff_walk_clim=. if inlist(hh_s3q14, .)
			tab1 w2_diff_walk_clim

		** Difficulty remembering or concentrating
			tab1 hh_s3q15, nol
			tab1 hh_s3q15
			gen w2_diff_reme=1 if inlist(hh_s3q15, 2, 3, 4) 
			replace w2_diff_reme=0 if inlist(hh_s3q15,1)
			replace w2_diff_reme=. if inlist(hh_s3q15, .)
			tab1 w2_diff_reme

		** Difficulty with self-care
			tab1 hh_s3q16, nol
			tab1 hh_s3q16
			gen w2_diff_self_care=1 if inlist(hh_s3q16, 2, 3, 4)
			replace w2_diff_self_care=0 if inlist(hh_s3q16, 1)
			replace w2_diff_self_care=. if inlist(hh_s3q16, .)
			tab1 w2_diff_self_care

		** Difficulty communicating
			tab1 hh_s3q17, nol
			tab1 hh_s3q17
			gen w2_diff_comm=1 if inlist(hh_s3q17, 2, 3, 4) 
			replace w2_diff_comm=0 if inlist(hh_s3q17, 1)
			replace w2_diff_comm=. if inlist(hh_s3q17, .)
			tab1 w2_diff_comm

			
	***********
	***********
	
	** SAVE
	
	keep hhid indiv w2*
	order hhid indiv w2*
	save "$dir/data/ETH_w2_individual.dta", replace
